<?php
class events_communities_composition extends composite_table {
	/**
	 * events table
	 *
	 * @var events
	 */
	public $events;
	/**
	 * communities_events table
	 *
	 * @var communities_events
	 */
	public $communities_events;

	/**
	 * Constructor
	 *
	 * @param mixed $id
	 */
	public function __construct($id = null) {
		parent::__construct($id);
	}

	/**
	 * Gets slave table relations as array of query_criteria objects where key is relation table
	 *
	 * @return array
	 */
	protected function get_tables_relations() {
		$out = array();

		$criteria = new query_criteria();

		$criteria->add_custom_criterion(sprintf("%s.%s = %s.%s",
		$this->events->get_table_name(), $this->events->event_id->get_field_name(),
		$this->communities_events->get_table_name(), $this->communities_events->event_id->get_field_name()));
		$out[] = new relations_wrapper($this->communities_events->get_table_name(), join_type::$inner, $criteria);

		return $out;
	}
}
?>